package com.yjzx.util.common.util.excel.alibaba;

import java.util.Arrays;
import java.util.List;

/**
 * @author yjzx
 * @date 2024/8/18
 * @description excel监听类构造
 */
public final class ExcelListenerBuilder implements ExcelListenerInterface {
    private List<List<String>> head;

    private ExcelListenerBuilder() {
    }

    public static ExcelListenerInterface getExcelListener(boolean isSkip) {
        return isSkip ? new SkipExcelListenerBuilder() : new ExcelListenerBuilder();
    }

    @Override
    @SafeVarargs
    public final ExcelListenerBuilder withHead(List<String>... heads) {
        this.head = Arrays.asList(heads);
        return this;
    }

    @Override
    public ExcelListenerBuilder withHead(List<List<String>> heads) {
        this.head = heads;
        return this;
    }

    @Override
    public ExcelListenerBuilder withHead(Class<?> head) {
        this.head = ExcelListener.classToExcelHead(head);
        return this;
    }

    @Override
    public <T> ExcelListener<T> build() {
        return new ExcelListener<>(this.head);
    }

}
